package com.ehotting.edsta.diagnosisPredict.controller;

import com.ehotting.eaf.core.domain.R;
import com.ehotting.eaf.core.web.controller.BaseController;
import com.ehotting.eaf.core.web.domain.diagnosisPredict.PageDto;
import com.ehotting.edsta.diagnosisPredict.domain.dto.FeCanvas;
import com.ehotting.edsta.diagnosisPredict.feign.FeCanvasFeignService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "FeCanvasController",description = "特征画布接口")
@RestController
@RequestMapping("/feCanvas")
public class FeCanvasController extends BaseController {

    @Autowired
    private FeCanvasFeignService canvasFeignService;


    /**
     * 根据id批量删除,逗号分隔ps:1,2,3，关联子表删除请重写
     *
     * @return
     */
    @ApiOperation(value = "根据id批量删除,逗号分隔ps:1,2,3，关联子表删除请重写",notes = "")
    @PostMapping(value = "/deleteByIds")
    public R<String> deleteByIds(@RequestParam String ids){
        return R.convert(canvasFeignService.deleteByIds(ids));
    }

    /**
     * 根据id查询
     *
     * @return
     */
    @ApiOperation(value = "根据id查询",notes = "返回的数据类型：FeCanvas")
    @ApiResponses(value = {
            @ApiResponse(code = 1,message = "",response = FeCanvas.class)
    })
    @GetMapping(value = "/getById")
    public R<FeCanvas> getById(@RequestParam Long id){
        return R.convert(canvasFeignService.getById(id));
    }

    /**
     * 列表
     *
     * @return
     */
    @ApiOperation(value = "列表",notes = "返回的数据类型：List\\<FeCanvas\\>")
    @GetMapping(value = "/list")
    public R<List<FeCanvas>> list(String createTime, String creater, String explains, Long id, String iteminfoId, String itemname, String name){
        return R.convert(canvasFeignService.list(createTime, creater, explains, id, iteminfoId, itemname,name));
    }

    /**
     * 特征画布字段列表列表
     *
     * @return
     */
    @ApiOperation(value = "特征画布字段列表列表",notes = "返回的数据类型：PageDto\\<FeCanvas\\>")
    @GetMapping(value = "/pageList")
    public R<PageDto<FeCanvas>> pageList(String createTime, String creater, String explains, Long id, String iteminfoId, String itemname, String name, Long page, Long pageSize){
        return R.convert(canvasFeignService.pageList(createTime, creater, explains, id, iteminfoId, itemname, name, page,pageSize));
    }

    /**
     * 特征画布字段列表保存
     *
     * @return
     */
    @ApiOperation(value = "特征画布字段列表保存",notes = "返回的数据类型：FeCanvas")
    @PostMapping(value = "/save")
    public R<FeCanvas> save(@RequestBody FeCanvas feCanvas){
        return R.convert(canvasFeignService.save(feCanvas));
    }

    /**
     * 根据数据的id修改或不存在id就添加
     *
     * @return
     */
    @ApiOperation(value = "根据数据的id修改或不存在id就添加",notes = "")
    @PostMapping(value = "/saveOrUpdate")
    public R<String> saveOrUpdate(@RequestBody FeCanvas t){
        return R.convert(canvasFeignService.saveOrUpdate(t));
    }

    /**
     * 根据数据的id批量修改或不存在id就批量添加
     *
     * @return
     */
    @ApiOperation(value = "根据数据的id批量修改或不存在id就批量添加",notes = "")
    @PostMapping(value = "/saveorUpdateBatch")
    public R<String> saveorUpdateBatch(@RequestBody FeCanvas[] t){
        return R.convert(canvasFeignService.saveorUpdateBatch(t));
    }

    /**
     * 修改
     *
     * @return
     */
    @ApiOperation(value = "修改",notes = "")
    @PostMapping(value = "/update")
    public R<String> update(@RequestBody FeCanvas t){
        return R.convert(canvasFeignService.update(t));
    }

    /**
     * 根据数据的id批量修改
     *
     * @return
     */
    @ApiOperation(value = "根据数据的id批量修改",notes = "")
    @PostMapping(value = "/updateList")
    public R<String> updateList(@RequestBody FeCanvas[] t){
        return R.convert(canvasFeignService.updateList(t));
    }
}
